/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.logistics.entity.outboundorder;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.cars.Tcar;
import com.jeesite.modules.base.entity.warehouse.Twarehouse;
import com.jeesite.modules.logistics.entity.inboundorder.InboundOrder;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 出库单Entity
 *
 * @author LV
 * @version 2021-03-10
 */
@Table(name = "t_outbound_order", alias = "a", columns = {
        @Column(name = "outbound_order_id", attrName = "outboundOrderId", label = "出库单ID", isPK = true),
        @Column(name = "outbound_order_code", attrName = "outboundOrderCode", label = "单据编号", queryType = QueryType.LIKE),
        @Column(name = "service_order_id", attrName = "serviceOrderId", label = "服务订单"),
        @Column(name = "frame_number", attrName = "frameNumber", label = "车架号", queryType = QueryType.LIKE),
        @Column(name = "car_id", attrName = "carId", label = "车辆名称", queryType = QueryType.LIKE),
        @Column(name = "from_warehouse_type", attrName = "fromWarehouseType", label = "出库仓类型"),
        @Column(name = "from_warehouse", attrName = "fromWarehouse", label = "出库仓"),
        @Column(name = "to_warehouse_type", attrName = "toWarehouseType", label = "目的仓类型"),
        @Column(name = "to_warehouse", attrName = "toWarehouse", label = "目的仓"),
        @Column(name = "date", attrName = "date", label = "出库时间"),
        @Column(name = "remarks", attrName = "remarks", label = "备注", isQuery = false),
        @Column(name = "transport_fleet", attrName = "transportFleet", label = "运输车队"),
        @Column(name = "car_number", attrName = "carNumber", label = "车牌号", isQuery = false),
        @Column(name = "driver_name", attrName = "driverName", label = "司机姓名", isQuery = false),
        @Column(name = "driver_phone", attrName = "driverPhone", label = "司机联系方式", isQuery = false),
        @Column(name = "create_by", attrName = "createBy", label = "创建者", isUpdate = false),
        @Column(name = "create_date", attrName = "createDate", label = "创建时间", isUpdate = false),
        @Column(name = "update_by", attrName = "updateBy", label = "更新者", isQuery = false),
        @Column(name = "update_date", attrName = "updateDate", label = "更新时间", isQuery = false),
        @Column(name = "inbound_order_code", attrName = "inboundOrderCode", label = "入库单"),
}, joinTable = {
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "b",
                on = "b.service_order_id = a.service_order_id",
                columns = {
                        @Column(name = "service_order_id", label = "服务订单ID", isPK = true),
                        @Column(name = "service_order_code", label = "服务订单编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Tcar.class, attrName = "tcar", alias = "c",
                on = "c.car_id = a.car_id",
                columns = {
                        @Column(name = "car_id", label = "车辆ID", isPK = true),
                        @Column(name = "car_name", label = "车辆编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Twarehouse.class, attrName = "fWarehouse", alias = "d",
                on = "d.warehouse_id = a.from_warehouse",
                columns = {
                        @Column(name = "warehouse_id", label = "出库仓ID", isPK = true),
                        @Column(name = "warehouse_name", label = "出库编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Twarehouse.class, attrName = "tWarehouse", alias = "e",
                on = "e.warehouse_id = a.to_warehouse",
                columns = {
                        @Column(name = "warehouse_id", label = "目的仓ID", isPK = true),
                        @Column(name = "warehouse_name", label = "目的仓编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = InboundOrder.class, attrName = "inboundOrder", alias = "f",
                on = "f.inbound_order_id = a.inbound_order_code",
                columns = {
                        @Column(name = "inbound_order_id", label = "入库单ID", isPK = true),
                        @Column(name = "inbound_order_code", label = "入库单编号"),
                }),
}, orderBy = "a.update_date DESC"
)
public class OutboundOrder extends DataEntity<OutboundOrder> {

    private static final long serialVersionUID = 1L;
    private String outboundOrderId;        // 出库单ID
    private String outboundOrderCode;        // 单据编号
    private String serviceOrderId;        // 服务订单
    private ServiceOrder serviceOrder;
    private String frameNumber;        // 车架号
    private String carId;        // 车辆名称
    private Tcar tcar;
    private String fromWarehouseType;        // 出库仓类型
    private String fromWarehouse;        // 出库仓
    private Twarehouse fWarehouse;
    private String toWarehouseType;        // 目的仓类型
    private String toWarehouse;        // 目的仓
    private Twarehouse tWarehouse;
    private Date date;        // 出库时间
    private String transportFleet;        // 运输车队
    private String carNumber;        // 车牌号
    private String driverName;        // 司机姓名
    private String driverPhone;        // 司机联系方式
    private String inboundOrderCode;        // 入库单
    private InboundOrder inboundOrder;

    public OutboundOrder() {
        this(null);
    }

    public OutboundOrder(String id) {
        super(id);
    }

    public String getOutboundOrderId() {
        return outboundOrderId;
    }

    public void setOutboundOrderId(String outboundOrderId) {
        this.outboundOrderId = outboundOrderId;
    }

    @Length(min = 0, max = 100, message = "单据编号长度不能超过 100 个字符")
    public String getOutboundOrderCode() {
        return outboundOrderCode;
    }

    public void setOutboundOrderCode(String outboundOrderCode) {
        this.outboundOrderCode = outboundOrderCode;
    }

    @Length(min = 0, max = 64, message = "服务订单长度不能超过 64 个字符")
    public String getServiceOrderId() {
        return serviceOrderId;
    }

    public void setServiceOrderId(String serviceOrderId) {
        this.serviceOrderId = serviceOrderId;
    }

    @NotBlank(message = "车架号不能为空")
    @Length(min = 0, max = 100, message = "车架号长度不能超过 100 个字符")
    public String getFrameNumber() {
        return frameNumber;
    }

    public void setFrameNumber(String frameNumber) {
        this.frameNumber = frameNumber;
    }

    @Length(min = 0, max = 64, message = "车辆名称长度不能超过 64 个字符")
    public String getCarId() {
        return carId;
    }

    public void setCarId(String carId) {
        this.carId = carId;
    }

    @Length(min = 0, max = 2, message = "出库仓类型长度不能超过 2 个字符")
    public String getFromWarehouseType() {
        return fromWarehouseType;
    }

    public void setFromWarehouseType(String fromWarehouseType) {
        this.fromWarehouseType = fromWarehouseType;
    }

    @Length(min = 0, max = 64, message = "出库仓长度不能超过 64 个字符")
    public String getFromWarehouse() {
        return fromWarehouse;
    }

    public void setFromWarehouse(String fromWarehouse) {
        this.fromWarehouse = fromWarehouse;
    }

    @NotBlank(message = "目的仓类型不能为空")
    @Length(min = 0, max = 2, message = "目的仓类型长度不能超过 2 个字符")
    public String getToWarehouseType() {
        return toWarehouseType;
    }

    public void setToWarehouseType(String toWarehouseType) {
        this.toWarehouseType = toWarehouseType;
    }

    @NotBlank(message = "目的仓不能为空")
    @Length(min = 0, max = 64, message = "目的仓长度不能超过 64 个字符")
    public String getToWarehouse() {
        return toWarehouse;
    }

    public void setToWarehouse(String toWarehouse) {
        this.toWarehouse = toWarehouse;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @NotNull(message = "出库时间不能为空")
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @NotBlank(message = "运输车队不能为空")
    @Length(min = 0, max = 2, message = "运输车队长度不能超过 2 个字符")
    public String getTransportFleet() {
        return transportFleet;
    }

    public void setTransportFleet(String transportFleet) {
        this.transportFleet = transportFleet;
    }

    @Length(min = 0, max = 50, message = "车牌号长度不能超过 50 个字符")
    public String getCarNumber() {
        return carNumber;
    }

    public void setCarNumber(String carNumber) {
        this.carNumber = carNumber;
    }

    @Length(min = 0, max = 50, message = "司机姓名长度不能超过 50 个字符")
    public String getDriverName() {
        return driverName;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    @Length(min = 0, max = 50, message = "司机联系方式长度不能超过 50 个字符")
    public String getDriverPhone() {
        return driverPhone;
    }

    public void setDriverPhone(String driverPhone) {
        this.driverPhone = driverPhone;
    }

    @Length(min = 0, max = 100, message = "入库单长度不能超过 100 个字符")
    public String getInboundOrderCode() {
        return inboundOrderCode;
    }

    public void setInboundOrderCode(String inboundOrderCode) {
        this.inboundOrderCode = inboundOrderCode;
    }

    public Date getDate_gte() {
        return sqlMap.getWhere().getValue("date", QueryType.GTE);
    }

    public void setDate_gte(Date date) {
        sqlMap.getWhere().and("date", QueryType.GTE, date);
    }

    public Date getDate_lte() {
        return sqlMap.getWhere().getValue("date", QueryType.LTE);
    }

    public void setDate_lte(Date date) {
        sqlMap.getWhere().and("date", QueryType.LTE, date);
    }

    public Date getCreateDate_gte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
    }

    public void setCreateDate_gte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
    }

    public Date getCreateDate_lte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
    }

    public void setCreateDate_lte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
    }

    public ServiceOrder getServiceOrder() {
        return serviceOrder;
    }

    public void setServiceOrder(ServiceOrder serviceOrder) {
        this.serviceOrder = serviceOrder;
    }

    public Tcar getTcar() {
        return tcar;
    }

    public void setTcar(Tcar tcar) {
        this.tcar = tcar;
    }

    public InboundOrder getInboundOrder() {
        return inboundOrder;
    }

    public void setInboundOrder(InboundOrder inboundOrder) {
        this.inboundOrder = inboundOrder;
    }

    public Twarehouse getfWarehouse() {
        return fWarehouse;
    }

    public void setfWarehouse(Twarehouse fWarehouse) {
        this.fWarehouse = fWarehouse;
    }

    public Twarehouse gettWarehouse() {
        return tWarehouse;
    }

    public void settWarehouse(Twarehouse tWarehouse) {
        this.tWarehouse = tWarehouse;
    }
}